package com.zhouyu;

import com.zhouyu.service.User;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.context.support.XmlWebApplicationContext;

import javax.servlet.ServletContext;

public class Test2 {
	public static void main(String[] args) {
		AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
		XmlWebApplicationContext root = new XmlWebApplicationContext();
		root.setConfigLocations("classpath:spring.xml");
		root.refresh();
		System.out.println("root.getBean(User.class) = " + root.getBean(User.class));

		System.out.println("-------------------");
		DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

		XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
		reader.loadBeanDefinitions("classpath:spring.xml");
		System.out.println("beanFactory.getBean(User.class) = " + beanFactory.getBean(User.class));

		System.out.println("-------------------");




	}
}
